#include "./SYSTEM/systick/systick.h"

static __IO uint32_t TimingDelay;

void Systick_Init() {
    if (SysTick_Config(SystemCoreClock / 1000000U)) {
        /* Capture error */
        while (1);
    }
}

/**
 * @brief  Inserts a delay time.
 * @param  nTime: specifies the delay time length, in microseconds.
 * @retval None
 */
void delay_us(__IO uint32_t nTime) {
    TimingDelay = nTime;

    while (TimingDelay != 0);
}

/**
 * @brief  Inserts a delay time.
 * @param  nTime: specifies the delay time length, in milliseconds.
 * @retval None
 */
void delay_ms(__IO uint32_t nTime) {
    TimingDelay = nTime * 1000;

    while (TimingDelay != 0);
}

/**
 * @brief  Decrements the TimingDelay variable.
 * @param  None
 * @retval None
 */
void TimingDelay_Decrement(void) {
    if (TimingDelay != 0x00) {
        --TimingDelay;
    }
}
